package com.kifas.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "tb_hutang")
public class HutangEntity implements Serializable {

	private static final long serialVersionUID = -1384245022439321432L;

	@Id
	@GeneratedValue
	@Column(name = "id_hutang")
	private Long idHutang;

	@Temporal(TemporalType.DATE)
	private Date tanggal;

	@Temporal(TemporalType.DATE)
	@Column(name = "tanggalJthTempo")
	private Date tanggalJatuhTempo;

	@Column(name = "syarat_bayar")
	private String syaratBayar;

	@Column(name = "no_faktur")
	private String noFaktur;

	@ManyToOne
	@JoinColumn(name = "id_supplier", nullable = false)
	private SupplierEntity supplier;

	private BigDecimal amount;

	private String keterangan;

	@Column(name = "no_ref")
	private String noRef;
	
	@OneToMany(mappedBy = "hutang", targetEntity = BukuHutangEntity.class, fetch = FetchType.LAZY)
	private List<BukuHutangEntity> bukuHutangs;
	
	@Column(name= "created_by")
	private String createdBy;
	
	@Column(name= "created_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdDate;

	public HutangEntity() {
	}

	public HutangEntity(Long idHutang, Date tanggal, Date tanggalJatuhTempo,
			String syaratBayar, String noFaktur, SupplierEntity supplier,
			BigDecimal amount, String keterangan, String noRef, String createdBy, Date createdDate) {
		this.idHutang = idHutang;
		this.tanggal = tanggal;
		this.tanggalJatuhTempo = tanggalJatuhTempo;
		this.syaratBayar = syaratBayar;
		this.noFaktur = noFaktur;
		this.supplier = supplier;
		this.amount = amount;
		this.keterangan = keterangan;
		this.noRef = noRef;
		this.createdBy = createdBy;
		this.createdDate = createdDate;
	}
	
	public HutangEntity(Long idHutang, Date tanggal, Date tanggalJatuhTempo,
			String syaratBayar, String noFaktur, SupplierEntity supplier,
			BigDecimal amount, String keterangan, String noRef, List<BukuHutangEntity> bukuHutangs, String createdBy, Date createdDate) {
		this.idHutang = idHutang;
		this.tanggal = tanggal;
		this.tanggalJatuhTempo = tanggalJatuhTempo;
		this.syaratBayar = syaratBayar;
		this.noFaktur = noFaktur;
		this.supplier = supplier;
		this.amount = amount;
		this.keterangan = keterangan;
		this.noRef = noRef;
		this.setBukuHutangs(bukuHutangs);
		this.createdBy = createdBy;
		this.createdDate = createdDate;
	}

	public Long getIdHutang() {
		return idHutang;
	}

	public void setIdHutang(Long idHutang) {
		this.idHutang = idHutang;
	}

	public Date getTanggal() {
		return tanggal;
	}

	public void setTanggal(Date tanggal) {
		this.tanggal = tanggal;
	}

	public Date getTanggalJatuhTempo() {
		return tanggalJatuhTempo;
	}

	public void setTanggalJatuhTempo(Date tanggalJatuhTempo) {
		this.tanggalJatuhTempo = tanggalJatuhTempo;
	}

	public String getSyaratBayar() {
		return syaratBayar;
	}

	public void setSyaratBayar(String syaratBayar) {
		this.syaratBayar = syaratBayar;
	}

	public String getNoFaktur() {
		return noFaktur;
	}

	public void setNoFaktur(String noFaktur) {
		this.noFaktur = noFaktur;
	}

	public SupplierEntity getSupplier() {
		return supplier;
	}

	public void setSupplier(SupplierEntity supplier) {
		this.supplier = supplier;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public String getKeterangan() {
		return keterangan;
	}

	public void setKeterangan(String keterangan) {
		this.keterangan = keterangan;
	}

	public String getNoRef() {
		return noRef;
	}

	public void setNoRef(String noRef) {
		this.noRef = noRef;
	}

	public void setBukuHutangs(List<BukuHutangEntity> bukuHutangs) {
		this.bukuHutangs = bukuHutangs;
	}

	public List<BukuHutangEntity> getBukuHutangs() {
		return bukuHutangs;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

}
